import Router from 'koa-router'
const router = new Router()
import {
  handleGetIceServersRequest, 
  handleCallRequest, 
  handleCreateOfferRequest, 
  handleSetAnswerRequest, 
  handleHangupRequest, 
  handleAddIceCandidateRequest, 
  handleGetIceCandidateRequest,
  handleHelpRequest
} from '../controllers/webrtc-controller.js'

// Define basic routes
router.get('/', async (ctx) => ctx.body = 'WebRTC signaling with Koa')
// Get the ICE server configuration
router.get('/api/getIceServers', handleGetIceServersRequest)
// Send offer and get answer
router.post('/api/call', handleCallRequest)
// Create an offer
router.get('/api/createOffer', handleCreateOfferRequest)
// Set an answer
router.post('/api/setAnswer', handleSetAnswerRequest)
// Close the call
router.get('/api/hangup', handleHangupRequest)
// Add ICE candidates
router.post('/api/addIceCandidate', handleAddIceCandidateRequest)
// Get a list of ICE candidates
router.get('/api/getIceCandidate', handleGetIceCandidateRequest)
// Help interface
router.get('/api/help', handleHelpRequest)

export default router
